package eu.connect.jmswrapper.callerproxies;

import Interaction.Invoke;
import Interaction.StarlinkURL;
import java.io.Serializable;
import eu.connect.jmswrapper.*;


public class InvokeJMSCallerProxy extends ConnectJMSCallerProxy implements Invoke {

	
//    @Override
    public Object[] invoke(StarlinkURL URL, String operation, Object[] parameters, String[] returnTypes) throws Exception {
        ConnectJMSInvokeMessage invokeMsg = new ConnectJMSInvokeMessage();
		invokeMsg.setMethodName("invoke");
		invokeMsg.setParameterTypes(new Class[]{StarlinkURL.class, String.class, Object[].class, String[].class});
		invokeMsg.setParameters(new Serializable[]{URL, operation, parameters, returnTypes});

		try {
			ConnectJMSSender sender = new ConnectJMSSender(invokeMsg,"Invoke");
			ConnectJMSReturnMessage returnMsg = sender.invoke();
			return (Object[]) returnMsg.getReturnObj();

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
    }
    @Override
    public Object[] send(StarlinkURL URL, String hh, Object[] parameters, String[] aas){
        ConnectJMSInvokeMessage invokeMsg = new ConnectJMSInvokeMessage();
		invokeMsg.setMethodName("send");
		invokeMsg.setParameterTypes(new Class[]{StarlinkURL.class, String.class, Object[].class, String[].class});
		invokeMsg.setParameters(new Serializable[]{URL, hh, parameters, aas});

		try {
			ConnectJMSSender sender = new ConnectJMSSender(invokeMsg,"Invoke");
			ConnectJMSReturnMessage returnMsg = sender.invoke();
			return (Object[]) returnMsg.getReturnObj();

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
    }

}
